<template>
    <div>
        <el-form label-position='left' label-width="0" size="small" :model="formData" :hide-required-asterisk='true' ref="editForm" class="add_form">
            <div class="flexbox flexcenter flexbetween">
                <el-radio-group v-model="formData.task_type" size="small" v-if="formData.task_type==0||formData.task_type==1">
                    <el-radio-button :label="0">带货达人视频</el-radio-button>
                    <el-radio-button :label="1">种草达人视频</el-radio-button>
                </el-radio-group>
                <div class="font_14 color_01" v-if="formData.task_type==3">选号条件设置</div>
                <el-date-picker style="width:260px" :picker-options="pickerOptions" :clearable="false" value-format="yyyyMMdd" v-model="formData.fg_options.date_type" type="daterange" size="small" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" v-if="formData.task_type !==2">
                </el-date-picker>
            </div>
            <div class="medium_box" :class="{'mt_20':formData.task_type !==2}">
                <div class="medium_title flexbox flexcenter">
                    <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path d="M4.57275 7.5973V3.92432C4.57275 3.41383 4.98043 3 5.48332 3H19.6622C20.1651 3 20.5728 3.41383 20.5728 3.92432V20.0757C20.5728 20.5862 20.1651 21 19.6622 21H5.48332C4.98043 21 4.57275 20.5862 4.57275 20.0757V15.9162" fill="#02A083" />
                        <path d="M4.57275 7.5973V3.92432C4.57275 3.41383 4.98043 3 5.48332 3H19.6622C20.1651 3 20.5728 3.41383 20.5728 3.92432V20.0757C20.5728 20.5862 20.1651 21 19.6622 21H5.48332C4.98043 21 4.57275 20.5862 4.57275 20.0757V15.9162V7.5973Z" stroke="#02A083" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" />
                        <path d="M16.3223 6H8.82227C8.13191 6 7.57227 6.55964 7.57227 7.25V16.75C7.57227 17.4404 8.13191 18 8.82227 18H16.3223C17.0126 18 17.5723 17.4404 17.5723 16.75V7.25C17.5723 6.55964 17.0126 6 16.3223 6Z" fill="white" />
                        <path d="M12.5726 9.35704L14.9282 9.35704M11.0723 11.9999L14.9279 11.9999M10.0723 15L14.9278 15" stroke="#02A083" stroke-width="1.45833" stroke-linecap="round" stroke-linejoin="round" />
                    </svg>
                    <span class="color_01">文件名称设置</span>
                    <span class="color_03">（不设置则使用系统默认名称）</span>
                </div>
                <div class="mt_20">
                    <el-form-item label="" prop="task_name" :rules="{required: true, message: '请设置文件名称', trigger: ['blur', 'change']}">
                        <el-input v-model="formData.task_name" size="small" placeholder="请设置文件名称" style="width:220px"></el-input>
                    </el-form-item>
                </div>
                <!-- <div class="bd_line mt_20"></div> -->
                <template v-if="formData.task_type=='0'">
                    <div class="medium_title flexbox flexcenter mt_20">
                        <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M6.46344 4.87597C6.52599 4.37554 6.95138 4 7.45573 4H17.6901C18.1945 4 18.6199 4.37554 18.6824 4.87597L20.4324 18.8759C20.507 19.4728 20.0416 20 19.4401 20H5.70571C5.10422 20 4.63883 19.4728 4.71344 18.8759L6.46344 4.87597Z" fill="#F79C69" stroke="#F79C69" stroke-width="1.5" stroke-linejoin="round" />
                            <path d="M8.07275 9C8.07275 9 9.07275 11 12.5728 11C16.0728 11 17.0728 9 17.0728 9" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
                        </svg>
                        <span class="color_01">商品集合</span>
                    </div>
                    <div class="mt_20" key="goods">
                        <el-input v-model="goodsId" size="small" placeholder="请输入商品 ID" style="width:220px" @keyup.enter.native="addId('gid_list')">
                            <i slot="suffix" style="font-style:normal;color:#17233D;margin-right:5px;line-height:34px">回车确定</i>
                        </el-input>
                        <el-form-item label="" :prop="`fg_options.gid_list`" :rules="{required: true, message: '请输入商品 ID', trigger: ['blur', 'change']}" style="margin-bottom:0">
                        </el-form-item>
                        <div class="flexbox flexcenter mt_12 flex_wrap">
                            <div class="feixing_has flexbox flexcenter" v-for="(item,index) in this.formData.fg_options.gid_list" :key="index">
                                <span class="color_02">{{item}}</span>
                                <span class="el-icon-close" @click="deletId(index,'gid_list')"></span>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="bd_line mt_12"></div> -->
                </template>
                <template v-else-if="formData.task_type=='1'">
                    <div class="medium_title flexbox flexcenter mt_20">
                        <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M5.67773 18L3.42773 8.29688L7.92773 10.4062L12.4277 4.5L16.9277 10.4062L21.4277 8.29688L19.1777 18H5.67773Z" fill="#AA68EC" stroke="#AA68EC" stroke-width="2" stroke-linejoin="round" />
                            <path d="M12.4277 15C13.2561 15 13.9277 14.3284 13.9277 13.5C13.9277 12.6716 13.2561 12 12.4277 12C11.5993 12 10.9277 12.6716 10.9277 13.5C10.9277 14.3284 11.5993 15 12.4277 15Z" fill="white" stroke="white" stroke-width="2" stroke-linejoin="round" />
                        </svg>
                        <span class="color_01">品牌集合</span>
                    </div>
                    <div class="mt_20" key="brands">
                        <el-input v-model="goodsId" size="small" placeholder="请输入品牌 ID" style="width:220px" @keyup.enter.native="addId('brand_list')">
                            <i slot="suffix" style="font-style:normal;color:#17233D;margin-right:5px;line-height:34px">回车确定</i>
                        </el-input>
                        <el-form-item label="" :prop="`fg_options.brand_list`" :rules="{required: true, message: '请输入品牌 ID', trigger: ['blur', 'change']}" style="margin-bottom:0">
                        </el-form-item>
                        <div class="flexbox flexcenter mt_12 flex_wrap">
                            <div class="feixing_has flexbox flexcenter" v-for="(item,index) in this.formData.fg_options.brand_list" :key="index">
                                <span class="color_02">{{item}}</span>
                                <span class="el-icon-close" @click="deletId(index,'brand_list')"></span>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="bd_line mt_12"></div> -->
                </template>
                <template v-else-if="formData.task_type=='3'">
                    <div class="medium_title flexbox flexcenter mt_20">
                        <img src="../../assets/img/medium_06.svg" alt="">
                        <span class="color_01">内容关键词</span>
                    </div>
                    <div class="mt_20" key="brands">
                        <el-input v-model="goodsId" size="small" placeholder="请输入视频关键词" style="width:220px" @keyup.enter.native="addId('keyword_list')">
                            <i slot="suffix" style="font-style:normal;color:#17233D;margin-right:5px;line-height:34px">回车确定</i>
                        </el-input>
                        <el-form-item label="" :prop="`fg_options.keyword_list`" :rules="{required: true, message: '请输入视频关键词', trigger: ['blur', 'change']}" style="margin-bottom:0">
                        </el-form-item>
                        <div class="flexbox flexcenter mt_12 flex_wrap">
                            <div class="feixing_has flexbox flexcenter" v-for="(item,index) in this.formData.fg_options.keyword_list" :key="index">
                                <span class="color_02">{{item}}</span>
                                <span class="el-icon-close" @click="deletId(index,'keyword_list')"></span>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="bd_line mt_12"></div> -->
                </template>
                <template v-if="formData.task_type !== 2">
                    <div class="flexbox flexcenter flexbetween mt_20">
                        <div class="medium_title flexbox flexcenter">
                            <img src="../../assets/img/medium_03.svg" alt="">
                            <span class="color_01">飞瓜筛选条件</span>
                        </div>
                        <el-link type="primary" :underline="false" @click="resetFgData">重置飞瓜条件</el-link>
                    </div>
                    <div class="flexbox flexcenter mt_20" key="max_like_count">
                        <div class="feigua_item">
                            <div class="font_12 color_02">视频点赞量大于</div>
                            <el-form-item label="" :prop="`fg_options.max_like_count`" :rules="{required: true, message: '请输入', trigger: ['blur', 'change']}" style="margin-bottom:0">
                                <el-input class="mt_12" oninput="value=value.replace(/[^\d.]/g,'')" v-model="formData.fg_options.max_like_count" size="small" placeholder="请输入" style="width:140px"></el-input>
                            </el-form-item>
                        </div>
                        <div class="feigua_item" key="blogger_fans">
                            <div class="font_12 color_02">达人粉丝量大于</div>
                            <el-form-item label="" :prop="`fg_options.blogger_fans`" :rules="{required: true, message: '请输入', trigger: ['blur', 'change']}" style="margin-bottom:0">
                                <el-input class="mt_12" oninput="value=value.replace(/[^\d.]/g,'')" v-model="formData.fg_options.blogger_fans" size="small" placeholder="请输入" style="width:140px"></el-input>
                            </el-form-item>
                        </div>
                        <div class="feigua_item" v-if="formData.task_type=='0'" key="sales_interval">
                            <div class="font_12 color_02">视频销售额大于</div>
                            <el-form-item label="" :prop="`fg_options.sales_interval`" :rules="{required: true, message: '请输入', trigger: ['blur', 'change']}" style="margin-bottom:0">
                                <el-input class="mt_12" oninput="value=value.replace(/[^\d.]/g,'')" v-model="formData.fg_options.sales_interval" size="small" placeholder="请输入" style="width:140px"></el-input>
                            </el-form-item>
                        </div>
                    </div>
                    <!-- <div class="bd_line mt_20"></div> -->
                </template>
                <template v-if="formData.task_type==2">
                    <div class="flexbox flexcenter flexbetween mt_20">
                        <div class="medium_title flexbox flexcenter">
                            <img src="../../assets/img/medium_05.svg" alt="">
                            <span class="color_01">排行榜筛选条件</span>
                        </div>
                    </div>
                    <div class="feixing_box fxing_right" key="two">
                        <div class="flexbox">
                            <div class="ranks_text">榜单</div>
                            <div class="flexbox flexcenter flex flex_wrap checked_list">
                                <el-radio-group v-model="formData.fg_options.top_type" @change="selectRanks">
                                    <el-radio :label="item.id" v-for="item in rankOption" :key="item.id">
                                        <div class="feixing_item">{{item.nickname}}</div>
                                    </el-radio>
                                </el-radio-group>
                            </div>
                        </div>
                        <div class="flexbox">
                            <div class="ranks_text">行业</div>
                            <div class="flexbox flexcenter flex flex_wrap checked_list">
                                <el-radio-group v-model="formData.fg_options.industry_type">
                                    <el-radio :label="item.id" v-for="item in industryOption" :key="item.id">
                                        <div class="feixing_item">{{item.nickname}}</div>
                                    </el-radio>
                                </el-radio-group>
                            </div>
                        </div>
                        <div class="flexbox">
                            <div class="ranks_text">日期</div>
                            <div class="flexbox flexcenter flex flex_wrap checked_list">
                                <el-radio-group v-model="formData.fg_options.date_type1">
                                    <template v-if="formData.fg_options.top_type!==3">
                                        <el-radio :label="1">
                                            <div class="feixing_item">日榜</div>
                                        </el-radio>
                                        <el-radio :label="7">
                                            <div class="feixing_item">周榜</div>
                                        </el-radio>
                                    </template>
                                    <el-radio :label="30">
                                        <div class="feixing_item">月榜</div>
                                    </el-radio>
                                </el-radio-group>
                            </div>
                        </div>
                    </div>
                </template>
                <XtModel :formData="formData" />
            </div>
        </el-form>
    </div>
</template>

<script>
import "@/assets/css/medium.css";
import XtModel from "./XtModel";
export default {
    props:[],
    components: {
        XtModel,
    },
    name: "",
    data() {
        return {
            pickerOptions: {
                shortcuts: [
                    {
                        text: "最近15天",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 16
                            );
                            end.setTime(
                                end.getTime() - 3600 * 1000 * 24 * 1
                            );
                            picker.$emit("pick", [start, end]);
                        },
                    },
                    {
                        text: "最近30天",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 31
                            );
                            end.setTime(
                                end.getTime() - 3600 * 1000 * 24 * 1
                            );
                            picker.$emit("pick", [start, end]);
                        },
                    },
                    {
                        text: "最近60天",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 91
                            );
                            end.setTime(
                                end.getTime() - 3600 * 1000 * 24 * 1
                            );
                            picker.$emit("pick", [start, end]);
                        },
                    },
                ],
            },
            goodsId: "",
            formData: {
                task_name: "",
                task_type: 0,
                field_list:[],//已选条件
                fg_options: {
                    gid_list: [], //商品ID
                    brand_list: [], //品牌ID
                    keyword_list: [], //关键词
                    max_like_count: "",
                    blogger_fans: "",
                    sales_interval: "",
                    date_type: [],
                    top_type: 0,
                    industry_type: 0,
                    date_type1: 1,
                },
                xt_options: {
                    price: {
                        price_1_20: {
                            min: "",
                            max: "",
                            unit: "￥",
                            text: "1-20s",
                            first_text: "星图价格",
                            second_text: "",
                            visible: false,
                            ischeck: false,
                        },
                        price_20_60: {
                            min: "",
                            max: "",
                            unit: "￥",
                            text: "20-60s",
                            first_text: "星图价格",
                            second_text: "",
                            visible: false,
                            ischeck: false,
                        },
                        price_60: {
                            min: "",
                            max: "",
                            unit: "￥",
                            text: "60s+",
                            first_text: "星图价格",
                            second_text: "",
                            visible: false,
                            ischeck: false,
                        },
                    },
                    audience: {
                        sex: {
                            sex_man: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "男",
                                first_text: "观众画像",
                                second_text: "性别分布",
                                visible: false,
                                ischeck: false,
                            },
                            sex_female: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "女",
                                first_text: "观众画像",
                                second_text: "性别分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        age: {
                            age_18_23: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "18-23",
                                first_text: "观众画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_24_30: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "24-30",
                                first_text: "观众画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_31_40: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "31-40",
                                first_text: "观众画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_41_50: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "41-50",
                                first_text: "观众画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_50: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "50+",
                                first_text: "观众画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        crowd: {
                            crowd_jzmm: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "精致妈妈",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xzqn: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "小镇青年",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_zsd: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "Z世代",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xrbl: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "新锐白领",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_dsll: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "都市蓝领",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_zszc: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "资深中产",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xzzln: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "小镇中老年",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_dsyf: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "都市银发",
                                first_text: "观众画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        device: {
                            iphone: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "苹果",
                                first_text: "观众画像",
                                second_text: "设备分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                    },
                    fans: {
                        sex: {
                            sex_man: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "男",
                                first_text: "粉丝画像",
                                second_text: "性别分布",
                                visible: false,
                                ischeck: false,
                            },
                            sex_female: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "女",
                                first_text: "粉丝画像",
                                second_text: "性别分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        age: {
                            age_18_23: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "18-23",
                                first_text: "粉丝画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_24_30: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "24-30",
                                first_text: "粉丝画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_31_40: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "31-40",
                                first_text: "粉丝画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_41_50: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "41-50",
                                first_text: "粉丝画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                            age_50: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "50+",
                                first_text: "粉丝画像",
                                second_text: "年龄分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        crowd: {
                            crowd_jzmm: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "精致妈妈",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xzqn: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "小镇青年",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_zsd: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "Z世代",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xrbl: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "新锐白领",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_dsll: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "都市蓝领",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_zszc: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "资深中产",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_xzzln: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "小镇中老年",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                            crowd_dsyf: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "都市银发",
                                first_text: "粉丝画像",
                                second_text: "八大人群",
                                visible: false,
                                ischeck: false,
                            },
                        },
                        device: {
                            iphone: {
                                min: "",
                                max: "",
                                unit: "%",
                                text: "苹果",
                                first_text: "粉丝画像",
                                second_text: "设备分布",
                                visible: false,
                                ischeck: false,
                            },
                        },
                    },
                },
            },
            rankOption: [
                {
                    id: 0,
                    nickname: "涨粉黑马榜",
                },
                {
                    id: 1,
                    nickname: "超值星选榜",
                },
                {
                    id: 2,
                    nickname: "头部必须榜",
                },
                {
                    id: 3,
                    nickname: "带货榜",
                },
            ],

            industryOption: [
                {
                    id: 0,
                    nickname: "全部",
                },
                {
                    id: 1,
                    nickname: "3C及电器",
                },
                {
                    id: 2,
                    nickname: "家居建材",
                },
                {
                    id: 3,
                    nickname: "教育",
                },
                {
                    id: 4,
                    nickname: "日化",
                },
                {
                    id: 5,
                    nickname: "服装配饰",
                },
                {
                    id: 6,
                    nickname: "汽车",
                },
                {
                    id: 7,
                    nickname: "美妆",
                },
                {
                    id: 8,
                    nickname: "食品饮料",
                },
            ],

            dataOption: [
                {
                    id: 1,
                    nickname: "日榜",
                },
                {
                    id: 7,
                    nickname: "周榜",
                },
                {
                    id: 30,
                    nickname: "月榜",
                },
            ],
        };
    },
    created() {
        this.getTimeFn();
    },
    methods: {
        getTimeFn() {
            const that = this;
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 31);
            end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
            that.formData.fg_options.date_type[0] = that.formatDate(start);
            that.formData.fg_options.date_type[1] = that.formatDate(end);
        },
        formatDate(date) {
            var myyear = date.getFullYear();
            var mymonth = date.getMonth() + 1;
            var myweekday = date.getDate();
            mymonth = mymonth < 10 ? "0" + mymonth : mymonth;
            myweekday = myweekday < 10 ? "0" + myweekday : myweekday;
            return myyear + mymonth + myweekday;
        },

        // 添加ID
        addId(val) {
            if (!this.goodsId.trim()) {
                return;
            } else {
                this.formData.fg_options[val].push(this.goodsId);
                this.goodsId = "";
            }
        },

        // 删除ID
        deletId(index, val) {
            this.formData.fg_options[val].splice(index, 1);
        },

        selectRanks() {
            if (this.formData.fg_options.top_type == 3) {
                this.formData.fg_options.date_type1 = 30;
            }
        },

        // 提交添加
        submitForm(formName) {
            this.$refs[formName].validate(async (valid) => {
                if (valid) {
                    let list = JSON.parse(JSON.stringify(this.formData));
                    list.fg_options.max_like_count =
                        list.fg_options.max_like_count !== ""
                            ? Number(list.fg_options.max_like_count)
                            : "";
                    list.fg_options.blogger_fans =
                        list.fg_options.blogger_fans !== ""
                            ? Number(list.fg_options.blogger_fans)
                            : "";
                    list.fg_options.sales_interval =
                        list.fg_options.sales_interval !== ""
                            ? Number(list.fg_options.sales_interval)
                            : "";
                    for (let i in list.xt_options) {
                        if (i == "price") {
                            for (let s in list.xt_options[i]) {
                                list.xt_options[i][s].min =
                                    list.xt_options[i][s].min !== ""
                                        ? Number(list.xt_options[i][s].min)
                                        : "";
                                list.xt_options[i][s].max =
                                    list.xt_options[i][s].max !== ""
                                        ? Number(list.xt_options[i][s].max)
                                        : "";
                                delete list.xt_options[i][s].unit;
                                delete list.xt_options[i][s].text;
                                delete list.xt_options[i][s].first_text;
                                delete list.xt_options[i][s].second_text;
                                delete list.xt_options[i][s].visible;
                                delete list.xt_options[i][s].ischeck;
                                delete list.xt_options[i][s].all_text;
                            }
                        } else {
                            for (let s in list.xt_options[i]) {
                                for (let a in list.xt_options[i][s]) {
                                    list.xt_options[i][s][a].min =
                                        list.xt_options[i][s][a].min !== ""
                                            ? Number(
                                                  list.xt_options[i][s][a].min
                                              )
                                            : "";
                                    list.xt_options[i][s][a].max =
                                        list.xt_options[i][s][a].max !== ""
                                            ? Number(
                                                  list.xt_options[i][s][a].max
                                              )
                                            : "";
                                    delete list.xt_options[i][s][a].unit;
                                    delete list.xt_options[i][s][a].text;
                                    delete list.xt_options[i][s][a].first_text;
                                    delete list.xt_options[i][s][a].second_text;
                                    delete list.xt_options[i][s][a].visible;
                                    delete list.xt_options[i][s][a].ischeck;
                                    delete list.xt_options[i][s][a].all_text;
                                }
                            }
                        }
                    }
                    if(list.task_type == 0){
                        let name_text= "文件名称："+this.formData.task_name
                        let goods_id= "商品ID："+this.formData.fg_options.gid_list.toString()
                        let likes_text= "视频点赞量大于："+this.formData.fg_options.max_like_count
                        let fans_text= "达人粉丝量大于："+this.formData.fg_options.blogger_fans
                        let sales_text= "视频销售额大于："+this.formData.fg_options.sales_interval
                        list.field_list = [name_text,goods_id,likes_text,fans_text,sales_text,...list.field_list]
                    }else if(list.task_type == 1){
                        let name_text= "文件名称："+this.formData.task_name
                        let brands_id= "品牌ID："+this.formData.fg_options.brand_list.toString()
                        let likes_text= "视频点赞量大于："+this.formData.fg_options.max_like_count
                        let fans_text= "达人粉丝量大于："+this.formData.fg_options.blogger_fans
                        list.field_list = [name_text,brands_id,likes_text,fans_text,...list.field_list]
                    }else if(list.task_type == 2){
                        let name_text= "文件名称："+this.formData.task_name
                        let rank_text= "榜单："+ this.rankOption.filter(item=>{return item.id == this.formData.fg_options.top_type})[0].nickname
                        let hangye_text= "行业："+ this.industryOption.filter(item=>{return item.id == this.formData.fg_options.industry_type})[0].nickname
                        let data_text= "日期："+ this.dataOption.filter(item=>{return item.id == this.formData.fg_options.date_type1})[0].nickname
                        list.field_list = [name_text,rank_text,hangye_text,data_text,...list.field_list]
                    }else if(list.task_type == 3){
                        let name_text= "文件名称："+this.formData.task_name
                        let key_id= "内容关键词："+this.formData.fg_options.keyword_list.toString()
                        let likes_text= "视频点赞量大于："+this.formData.fg_options.max_like_count
                        let fans_text= "达人粉丝量大于："+this.formData.fg_options.blogger_fans
                        list.field_list = [name_text,key_id,likes_text,fans_text,...list.field_list]
                    }
                    console.log(list);
                    // return
                    this.$parent.loading = true;
                    const { data: res } = await this.$http.post(
                        "https://meijie.jcmasz.com:8910/create_task",
                        list,
                        {
                            headers: {
                                "content-type":
                                    "application/x-www-form-urlencoded; Charset=UTF-8",
                                Accept: "application/json, text/plain, */*",
                            },
                        }
                    );
                    if (res.code !== 200) {
                        this.$parent.loading = false;
                        this.$message.error(res.msg);
                        return;
                    } else {
                        this.$parent.loading = false;
                        this.$message({
                            message: res.msg,
                            type: "success",
                        });
                    }
                } else {
                    this.$parent.loading = false;
                    return false;
                }
            });
        },

        // 重置飞瓜数据
        resetFgData() {
            this.formData.fg_options.max_like_count = "";
            this.formData.fg_options.sales_interval = "";
            this.formData.fg_options.blogger_fans = "";
        },
    },
};
</script>


<style scoped>
</style>


